import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_book_store/routes/app_pages.dart';
import 'package:get/get.dart';

class SettingPage extends GetView {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          ItemBar(
            onTap: () {
              Get.toNamed(Routes.USERINFO);
            },
            text: '个人信息设置',
          ),
          ItemBar(
            onTap: () {
              Get.toNamed(Routes.CHANGE_PWD);
            },
            text: '密码设置',
          ),
          SizedBox(
            height: 10,
          ),
          InkWell(
            onTap: () {
              Get.toNamed(Routes.LOGIN);
            },
            child: Container(
              width: double.infinity,
              color: Colors.white,
              padding: EdgeInsets.all(15),
              child: Center(
                child: Text(
                  '切换账号',
                  style: TextStyle(fontSize: 16, color: Colors.black),
                ),
              ),
            ),
          ),
          SizedBox(
            height: 10,
          ),
          InkWell(
            onTap: (){
              Get.toNamed(Routes.LOGIN);
            },
            child: Container(
              width: double.infinity,
              color: Colors.white,
              padding: EdgeInsets.all(15),
              child: Center(
                child: Text(
                  '退出登录',
                  style: TextStyle(fontSize: 16, color: Colors.black),
                ),
              ),
            ),
          ),
        ],
      ),
      appBar: AppBar(
        leading: IconButton(
          onPressed: () {
            Get.back();
          },
          icon: Icon(
            Icons.arrow_back_ios,
            color: Colors.blue,
          ),
        ),
        title: Text('设置'),
      ),
    );
  }
}

class ItemBar extends StatelessWidget {
  final text;
  final onTap;

  const ItemBar({Key key, this.text, this.onTap}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        color: Colors.white,
        padding: EdgeInsets.all(15),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Row(mainAxisAlignment: MainAxisAlignment.start, children: [
              SizedBox(
                width: 10,
              ),
              Text(
                text,
                style: TextStyle(fontSize: 16, color: Colors.black),
              )
            ]),
            Icon(
              Icons.chevron_right,
              size: 20,
            ),
          ],
        ),
      ),
    );
  }
}
